/*
*************************************************************************
*西瑞克斯研发管理系统
*版 本: 1.0   
*日 期：02/11/2012    
*作 者： 王浩 QQ：873987060   
*************************************************************************   
*/ 
package com.manager.commons;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;

import com.application.usertable.entity.Usertable;

public class CurrentUserFilter implements Filter {

 

	public void init(FilterConfig arg0) throws ServletException {
		 
	}

	public void doFilter(ServletRequest request, ServletResponse response,
			FilterChain chain) throws IOException, ServletException {
		HttpServletRequest req = (HttpServletRequest) request;
		Usertable user = (Usertable)req.getSession().getAttribute("loginUser");
		//将user设置到thread local变量中
		CurrentUserUtils.setCurrentUser(user);
		chain.doFilter(request, response);
	}

	public void destroy() {
 
	}

}
